package toutiao

import (
	"github.com/astaxie/beego/orm"
	"log"
	"time"
)

type Keyword struct {
	Id      int64  `orm:"pk;auto"`
	Name    string `orm:"unique"`
	Status  int
	UrlInfo []*UrlInfo `orm:"reverse(many)"` // 设置一对多的反向关系
	Picture []*Picture `orm:"reverse(many)"`
	Url     []*Url     `orm:"reverse(many)"`
	Addtime time.Time  `orm:"auto_now_add;type(datetime)"`
}

func GetKeywords() (keywords []Keyword) {
	o := orm.NewOrm()
	_, err := o.QueryTable("keyword").Filter("status", 1).All(&keywords)
	if err != nil {
		log.Println(err)
	}
	return
}
